#!/bin/bash

make

EXE="main"

if [[ "$OSTYPE" =~ ^msys ]]; then
    EXE="main.exe"
fi

if [ ! -f "$EXE" ]; then
    echo "ERROR"
    exit
fi

for i in {1..10}; do
    p=(./result/$i/)
    ./$EXE
    echo $p
    mkdir $p
    cp tspgacurve.txt $p
    cp tsppath.txt $p
done

for i in {1..10}; do
    p=(./result/${i}/tspgacurve.txt)
    echo -n ${i} '  '
    for j in {1..100}; do
        line=$(expr ${j} \* 1)
        con=$(cat ${p} | head -n ${line} | tail -n 1)
        IFS=' '                  #setting comma as delimiter
        read -a strarr <<<"$con" #reading str as an array as tokens separated by IFS
        res=${strarr[1]}
        echo -n ${res} '    '
    done
    echo
done
